define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'baobiao/material/index' + location.search,
                    table: 'material',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'create_date', title: "日期"},
                        {field: 'factory', title: "供应商"},
                        {field: '', title: "单据类型", operate: 'LIKE'},
                        {field: 'depot', title: "库位",operate: false},
                        {field: 'material', title: "物料类型",operate: false},
                        {field: 'category', title: "品类",operate: false},
                        {field: '', title: "批次",operate: false},
                        {field: '', title: "使用阶段",operate: false},
                        {field: 'code', title: "物料编码",operate: false},
                        {field: 'name', title: "物料名称",operate: false},
                        {field: 'specs', title: "规格",operate: false},
                        {field: 'anum', title: "数量",operate: false},
                        {field: 'unit', title: "单位",operate: false},
                        {field: 'price', title: "单价",operate: false},
                        {field: 'total_price', title: "金额",operate: false},
                        {field: '', title: "销售单价",operate: false},
                        {field: '', title: "销售金额",operate: false},
                        {field: '', title: "备注",operate: false},
                        {field: '', title: "客户",operate: false},
                        {field: '', title: "业务员",operate: false},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
